#include <iostream>
#include "Line.hpp"
using namespace std;
// 这是一个实现文件，不用包含测试，只需要实现头文件中的函数等内容
//先对成员类型进行实现
class Line::LineImpl
{
public:
    class Point{
    public:
        Point(int x,int y)
        : _ix(x)
        , _iy(y)
        {
            cout << "Point()" << endl;
        }
        ~Point()
        {
            cout << "~Point()" << endl;
        }
        void print()
        {
            cout << "("<<_ix << "," 
                << _iy << ")";
        }
    private:
        int _ix;
        int _iy;
    };
public:
    LineImpl(int x1, int y1, int x2, int y2)
    : _pt1(x1,y1)
    , _pt2(x2,y2)
    {
        cout << "LineImpl(int *4)" << endl;
    }
    ~LineImpl()
    {
        cout << "~LineImpl()" << endl;
    }
    void printline()
    {
        _pt1.print();
        cout << "-----> ";
        _pt2.print();
        cout << endl;
    }
private: 
    Point _pt1;
    Point _pt2;
};

Line::Line(int x1, int y1, int x2, int y2)
    :_pimpl(new LineImpl(x1,y1, x2,y2))
{
    cout << "Line(int * 4)" << endl;
}
Line :: ~Line()
{
    cout << "~Line()" << endl;
    if(_pimpl)
    {
        delete _pimpl;
        _pimpl = nullptr;
    }
}
void Line::printLine() const{
    _pimpl->printline();
}